package main

import (
	"fmt"
	//"math/rand"
	"time"
)

func main() {
	timerPool := make(chan *time.Timer, 2000)
	for i := 0; i < 2000; i++ {
		timerPool <- time.NewTimer(0 * time.Second)
	}

	for i := 0; i < 100000000; i++ {
		t := <-timerPool
		t.Reset(time.Second * 2)
		select {
		case <-t.C:
		case <-func() chan bool {
			//time.Sleep(time.Microsecond * time.Duration(100+rand.Intn(1000)))
			c := make(chan bool, 1)
			c <- true
			return c
		}():
		}
		t.Stop()
		t.Reset(0)
		timerPool <- t
		fmt.Println(time.Now())
	}
}
